﻿
Ext.ns('SafeBox.Store');

SafeBox.Store.UserStore = Ext.extend(Ext.data.Store, {
    storeId: 'SafeBox.Store.UserStore',
    autoload: true,
    autoSave: true,
    listeners: {
        datachanged: function () {
            this.save();
        }
    },
    check: function (user, pwd) {
        var _index = this.findExact('user', user);
        if (_index != -1) {
            var _r = this.getAt(_index);
            if (_r.data.password === pwd) {
                return Constants.LoginResult.Success;
            }
            else {
                return Constants.LoginResult.PasswordNotMatch;
            }
        }
        else {
            return Constants.LoginResult.UserNotExist;
        }
    },
    getCount: function () {
        return this.data.length;
    }
});